﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace QFramework.Pacman
{
	public class PacmanGame
	{
		public static IQFrameworkContainer Container
		{
			get
			{
				if (mContainer == null)
				{
					mContainer = new QFrameworkContainer();

					InitContainer(mContainer);
				}

				return mContainer;
			}
		}

		private static IQFrameworkContainer mContainer = null;

		static void InitContainer(IQFrameworkContainer container)
		{
			container.RegisterInstance(new PacmanModel());
		}
	}


	public static class PacmanGameExtensions
	{
		public static void InjectToSelf<T>(this T self) where T : MonoBehaviour
		{
			PacmanGame.Container.Inject(self);
		}

		public static T Resolve<T>(this MonoBehaviour self) where T : class
		{
			return PacmanGame.Container.Resolve<T>();
		}

		public static PacmanModel Model(this MonoBehaviour self)
		{
			return PacmanGame.Container.Resolve<PacmanModel>();
		}
	}
}